package com.cxy.controller;

import com.cxy.pojo.Staff;
import com.cxy.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.time.Period;

/**
 * @author 蔡心勇
 * @create 2022/3/15 - 16:47
 */
@Controller
@RequestMapping("/staff")
public class staffController {

    @Autowired
    private StaffService staffService;

    @RequestMapping("/addStaff")
    public ModelAndView addStaff(Staff staff){
        ModelAndView modelAndView=new ModelAndView();
        int res = staffService.addStaff(staff);
        if (res>0){
            modelAndView.addObject("msg","添加成功");
        }else {
            modelAndView.addObject("msg","失败");
        }
        modelAndView.setViewName("show");
        return modelAndView;
    }
}
